﻿using System;

using Exif.Exceptions;
using Exif.Interfaces;

using PostSharp.Laos;

namespace Exif.Aspects
{
	[Serializable]
	public class InitializableAttribute : OnMethodInvocationAspect
	{
		public override void OnInvocation(MethodInvocationEventArgs eventArgs)
		{
			var init = eventArgs.Delegate.Target as IInitializeNotification;
			if (init != null && !init.IsInitialized)
			{
				throw new NotInitializedException();
			}

			eventArgs.Proceed();
		}
	}
}